package com.jdk.demo.fileChannel.openfile;

import java.io.File;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

public class CreateNew {
	
	// 创建一个新文件，如果该文件已存在，则失败
	public static void main(String[] args) throws Exception {
		File file = new File("q.txt");
		Path path = file.toPath();
		FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
		fileChannel.close();
	}

}
